package com.asl.website.aslMyaslIntro.domain;

import com.asl.common.utils.StringUtils;
import com.asl.website.common.Language;

public class MyaslIntroDTO {
    private Long id;
    private String part;
    private String title;
    private String content;
    private Integer sortOrder;

    public MyaslIntroDTO(AslMyaslIntro entity, String language) {
        this.id = entity.getId();
        this.sortOrder = entity.getSortOrder() != null ? entity.getSortOrder().intValue() : 0;

        switch (Language.fromCode(language)) {
            case EN_US:
                this.title = StringUtils.firstNonBlank(entity.getTitleEn(), entity.getTitleZh());
                this.content = StringUtils.firstNonBlank(entity.getContentEn(), entity.getContentZh());
                break;
            case DE_DE:
                this.title = StringUtils.firstNonBlank(entity.getTitleDe(), entity.getTitleZh());
                this.content = StringUtils.firstNonBlank(entity.getContentDe(), entity.getContentZh());
                break;
            default: // 默认中文
                this.title = entity.getTitleZh();
                this.content = entity.getContentZh();
        }
    }

    // Getters
    public Long getId() {
        return id;
    }

    public String getPart() {
        return part;
    }

    public String getTitle() {
        return title;
    }

    public String getContent() {
        return content;
    }



    public Integer getSortOrder() {
        return sortOrder;
    }
}